<template>
	<view>
		<view class="topSelect">
			<view class="topSelect-left">
				<view v-if="hasItem('shijian')" class="topSelect-item" @click="timeSelect('dateTime')">
					<span>{{queryParams.dateTime?queryParams.dateTime:'时间'}}</span>
					<u-icon name="arrow-down-fill" class="icon-tip" color="#999" size="10"></u-icon>
				</view>
				<view v-if="hasItem('gongyingshang')" class="topSelect-item" @click="showPop('gongyingshang',typeList)">
					<span class="nimilt">{{queryParams.gongyingshang?queryParams.gongyingshang:'供应商'}}</span>
					<u-icon name="arrow-down-fill" class="icon-tip" color="#999" size="10"></u-icon>
				</view>
				<view  v-if="hasItem('pinwei')" class="topSelect-item" @click="showPop('type',typeList)">
					<span class="nimilt">{{queryParams.type?queryParams.type:'品味'}}</span>
					<u-icon name="arrow-down-fill" class="icon-tip" color="#999" size="10"></u-icon>
				</view>
				<view v-if="hasItem('shenqingshijian')" class="topSelect-item" @click="timeSelect('shenqingshijian')">
					<span>{{queryParams.shenqingshijian?queryParams.shenqingshijian:'申请时间'}}</span>
					<u-icon name="arrow-down-fill" class="icon-tip" color="#999" size="10"></u-icon>
				</view>
				<view v-if="hasItem('cangku')" class="topSelect-item" @click="showPop('cangku',typeList)">
					<span class="nimilt">{{queryParams.cangku?queryParams.cangku:'仓库'}}</span>
					<u-icon name="arrow-down-fill" class="icon-tip" color="#999" size="10"></u-icon>
				</view>
				<view v-if="hasItem('shengchanriqi')" class="topSelect-item" @click="timeSelect('shengchanriqi')">
					<span>{{queryParams.shengchanriqi?queryParams.shengchanriqi:'生产时间'}}</span>
					<u-icon name="arrow-down-fill" class="icon-tip" color="#999" size="10"></u-icon>
				</view>
				<view  v-if="hasItem('danjia')"  class="topSelect-item" @click="sortSingle">
					<span>单价</span>
					<!-- <u-icon name="arrow-downward" class="icon-tip" color="#757575" size="12"></u-icon> -->
					<!-- <u-icon name="arrow-upward" class="icon-tip" color="#757575" size="12"></u-icon> -->
				</view>
				<view  v-if="hasItem('zongjia')"  class="topSelect-item" @click="sortSingle()">
					<span>总价</span>
					<!-- <u-icon name="arrow-downward" class="icon-tip" color="#757575" size="12"></u-icon> -->
					<!-- <u-icon name="arrow-upward" class="icon-tip" color="#757575" size="12"></u-icon> -->

				</view>
				<view  v-if="hasItem('shuliang')"  class="topSelect-item" @click="sortSingle()">
					<span>数量</span>
					<!-- <u-icon name="arrow-downward" class="icon-tip" color="#757575" size="12"></u-icon> -->
					<!-- <u-icon name="arrow-upward" class="icon-tip" color="#757575" size="12"></u-icon> -->
				
				</view>
				<view  v-if="hasItem('yuanjia')"  class="topSelect-item" @click="sortSingle()">
					<span>原价</span>
					<!-- <u-icon name="arrow-downward" class="icon-tip" color="#757575" size="12"></u-icon> -->
					<!-- <u-icon name="arrow-upward" class="icon-tip" color="#757575" size="12"></u-icon> -->
				
				</view>
			</view>
			<span class="search-reset" @click="reset">重置</span>
		</view>
		<u-datetime-picker :show="showinTime" :value="inTime" mode="date" closeOnClickOverlay @confirm="TimeConfirm"
			@cancel="TimeClose" @close="TimeClose"></u-datetime-picker>

		<u-action-sheet :show="isShowPop" :actions="actions" title="请选择" @close="isShowPop = false"
			@select="popSelect"></u-action-sheet>
	</view>


</template>

<script>
	import db from '@/common/localstorage.js'
	export default {
		props:['items'],
		
		data() {
			return {
				showinTime: false,
				inTime: Number(new Date()),
				timeType: '',
				queryParams: {
					dateTime:'',
					type:'',
					cangku:'',
					gongyingshang:'',
					shenqingshijian:'',
					shengchanriqi:'',
				},

				isShowPop: false,
				popType: '',
				actions: [],
				typeList: [{
					name: '品味品味为都是',
					id: 1
				},{
					name: '供应商供应商',
					id: 2
				}]
			}
		},
		onLoad() {

		},

		methods: {
			hasItem(permissions) {
			  return this.items.some(item => {
			    return item == permissions
			  })
			},
			
			reset(){
				for (let key in this.queryParams) {
				  this.queryParams[key] = ''
				}
			},
			sortSingle() {},
			showPop(type, list) {
				this.actions = list
				this.popType = type
				this.isShowPop = true
			},
			popSelect(e) {
				this.queryParams[this.popType] = e.name
			},
			timeSelect(type) {
				this.timeType = type
				this.showinTime = true
			},

			TimeClose() {
				this.showinTime = false
			},
			TimeConfirm(e) {
				this.showinTime = false
				this.queryParams[this.timeType] =uni.$u.timeFormat(e.value, 'yyyy.mm.dd')
			},


		},

	}
</script>

<style lang="scss" scoped>
	.topSelect {
		// padding:8upx 0upx 28upx 0upx;
		display: flex;
		align-items: center;
		justify-content: space-between;

		.topSelect-item {
			font-family: PingFangSC, PingFang SC;
			font-weight: 400;
			font-size: 28rpx;
			color: #666666;
			display: flex;
			align-items: center;
		}

		.nimilt {
			display: inline-block;
			max-width: 120upx;
			overflow: hidden;
			white-space: nowrap;
		}

		.icon-tip {
			margin-top: 4upx;
			margin-left: 4upx;
		}

		.topSelect-item-icon {
			margin-left: 10upx;
			display: flex;
			flex-direction: column;
		}

		.topSelect-item-active {
			font-weight: 600;
			font-size: 32rpx;
			color: #111111;
		}
	}

	.topSelect-left {
		width: calc(100% - 120upx);
		display: flex;
		align-items: center;
		justify-content: space-between;
	}

	.search-reset {
		font-family: PingFangSC, PingFang SC;
		font-weight: 400;
		font-size: 28rpx;
		color: #11AA66;
		margin-left: 60upx;
	}
</style>